package cn.suse.android.logic;

import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;


import cn.suse.android.entity.Actor;
import cn.suse.android.entity.UserActive;
import cn.suse.android.entity.publishedTime;
import cn.suse.android.logic.BaseParse;

/**
 * @author liubin
 *
 * Create DateTime:Sep 20, 2012 10:26:08 AM
 *
 * @Version: 1.0.0
 */
public class UserActiveParse extends BaseParse<UserActive> {

	/* (non-Javadoc)
	 * @see cn.suse.android.utils.BaseParse#parse(java.lang.String)
	 */
	@Override
	public List<UserActive> parseData(String content) {
		// TODO Auto-generated method stub
		List<UserActive> lists = null;
		try {
			JSONArray json = new JSONArray(content);
			JSONArray jsonArray = json.getJSONArray(1);
			for(int i=0;i<jsonArray.length();i++){
				JSONObject jsonObject = jsonArray.getJSONObject(i);
				UserActive userActive = new UserActive();
				userActive.setComments(jsonObject.getString("comments"));
				userActive.setDescription(jsonObject.getString("description"));
				userActive.setFeed_id(jsonObject.getString("feed_id"));
				userActive.setForward(jsonObject.getString("forward"));
				userActive.setLikes(jsonObject.getString("likes"));
				userActive.setPic_cover(jsonObject.getString("pic_cover"));
				userActive.setVerb(jsonObject.getString("verb"));
				publishedTime publishedTime = new publishedTime();
				publishedTime.setCtime(jsonObject.getJSONObject("published").getString("ctime"));
				publishedTime.setStime(jsonObject.getJSONObject("published").getString("stime"));
				userActive.setPublished(publishedTime);
				Actor actor = new Actor();
				actor.setLogo50(jsonObject.getJSONObject("actor").getString("logo50"));
				actor.setUid(jsonObject.getJSONObject("actor").getString("uid"));
				actor.setName(jsonObject.getJSONObject("actor").getString("name"));
				userActive.setActor(actor);
				lists.add(userActive);
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
		return lists;
	}

}
